package com.university.mentalhealthplatform.teacherV2.service;

import com.university.mentalhealthplatform.appModels.Task;
import com.university.mentalhealthplatform.teacherV2.repository.TaskRepositoryV2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TaskServiceV2 {

    @Autowired
    private TaskRepositoryV2 taskRepositoryV2;

    public List<Task> getAllTasks() {
        return taskRepositoryV2.findAll();
    }

    public Task getTaskById(Long id) {
        return taskRepositoryV2.findById(id).orElse(null);
    }

    public Task saveTask(Task task) {
        return taskRepositoryV2.save(task);
    }

    public void deleteTask(Long id) {
        taskRepositoryV2.deleteById(id);
    }
}